>categoria.sql
>cat.list
>rifiuto.sql
N=1
sort mat | uniq | while read L
do
	echo "insert into categoria values($N,$L);" >> categoria.sql
	echo "$L" >>cat.list
	N=$(($N + 1))
done
#sort mat | while read L
#do
#	grep -n "$L" cat.list
#done 
N=1
cat rif | while read R
do
	MAT=$(head -$N mat | tail -1)
	echo MAT $MAT
	NMAT=$(grep -n "$MAT" cat.list | cut -d":" -f1)
	echo $R $NMAT $MAT
	echo "insert into rifiuto values($N,$R,$NMAT);" >> rifiuto.sql
	N=$(($N + 1))
done
